package com.cf.data.serve.mq;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * RabbitMQ配置类
 * @author
 **/
@Configuration
public class DirectRabbitMqConfig
{
    //人脸
    public static final String DIRECT_QUEUE_NAME = "issued_face_queue";
    //门禁
    public static final String DIRECT_QUEUE_NAME2 = "issued_mj_queue";
    //通用事件
    public static final String DIRECT_QUEUE_NAME3 = "issued_common_queue";

    //交换器名称
    public static final String DIRECT_EXCHANGE_NAME = "issued_exchange";
    //路由键 人脸
    public static final String DIRECT_ROUTING_KEY = "issued_face_key";
    //路由键 门禁
    public static final String DIRECT_ROUTING_KEY2 = "issued_mj_key";
    //通用事件
    public static final String DIRECT_ROUTING_KEY3 = "issued_common_key";

    //人脸比对消息
    public static final String ALARM_QUEUE_NAME = "alarm_comparison_queue";
    //安全帽检测
    public static final String ALARM_QUEUE_NAME2 = "alarm_other_queue";
    //门禁消息
    public static final String ALARM_QUEUE_NAME3 = "mj_queue";
    //交换器名称
    public static final String ALARM_EXCHANGE_NAME = "alarm_comparison_exchange";
    //路由键
    public static final String ALARM_ROUTING_KEY = "alarm_comparison_key";
    public static final String ALARM_ROUTING_KEY2 = "alarm_other_key";
    public static final String ALARM_ROUTING_KEY3 = "mj_key";


    @Bean
    public Queue directQueue()
    {
        return new Queue(DIRECT_QUEUE_NAME, true, false, false, null);
    }

    @Bean
    public Queue directQueue2()
    {
        return new Queue(DIRECT_QUEUE_NAME2, true, false, false, null);
    }
    @Bean
    public Queue directQueue3()
    {
        return new Queue(DIRECT_QUEUE_NAME3, true, false, false, null);
    }

    /**
     * alarm队列
     */
    @Bean
    public Queue alarmQueue()
    {

        return new Queue(ALARM_QUEUE_NAME, true, false, false, null);
    }
    /**
     * alarm队列
     */
    @Bean
    public Queue alarmQueue2()
    {

        return new Queue(ALARM_QUEUE_NAME2, true, false, false, null);
    }

    /**
     * alarm队列3
     */
    @Bean
    public Queue alarmQueue3()
    {
        return new Queue(ALARM_QUEUE_NAME3, true, false, false, null);
    }

    @Bean
    public DirectExchange directExchange()
    {
        return new DirectExchange(DIRECT_EXCHANGE_NAME, true, false);
    }
    /**
     * Direct交换器
     */
    @Bean
    public DirectExchange alarmExchange()
    {

        return new DirectExchange(ALARM_EXCHANGE_NAME, true, false);
    }

    @Bean
    Binding bindingDirect(DirectExchange directExchange,Queue directQueue)
    {
        //将队列和交换机绑定, 并设置用于匹配键：routingKey
        return BindingBuilder.bind(directQueue).to(directExchange).with(DIRECT_ROUTING_KEY);
    }

    @Bean
    Binding bindingDirect2(DirectExchange directExchange,Queue directQueue2)
    {
        //将队列和交换机绑定, 并设置用于匹配键：routingKey
        return BindingBuilder.bind(directQueue2).to(directExchange).with(DIRECT_ROUTING_KEY2);
    }

    /**
     * 绑定2
     */
    @Bean
    Binding bindingDirect3(DirectExchange directExchange,Queue directQueue3)
    {
        //将队列和交换机绑定, 并设置用于匹配键：routingKey
        return BindingBuilder.bind(directQueue3).to(directExchange).with(DIRECT_ROUTING_KEY3);
    }

    /**
     * 绑定
     */
    @Bean
    Binding bindingAlarmDirect(DirectExchange alarmExchange,Queue alarmQueue)
    {
        //将队列和交换机绑定, 并设置用于匹配键：routingKey
        return BindingBuilder.bind(alarmQueue).to(alarmExchange).with(ALARM_ROUTING_KEY);
    }

    /**
     * 绑定2
     */
    @Bean
    Binding bindingAlarmDirect2(DirectExchange alarmExchange,Queue alarmQueue2)
    {
        //将队列和交换机绑定, 并设置用于匹配键：routingKey
        return BindingBuilder.bind(alarmQueue2).to(alarmExchange).with(ALARM_ROUTING_KEY2);
    }

    /**
     * 绑定2
     */
    @Bean
    Binding bindingAlarmDirect3(DirectExchange alarmExchange,Queue alarmQueue3)
    {
        //将队列和交换机绑定, 并设置用于匹配键：routingKey
        return BindingBuilder.bind(alarmQueue3).to(alarmExchange).with(ALARM_ROUTING_KEY3);
    }

}